package org.oslims.client.view.impl;

import org.oslims.client.uicomponents.ConfirmationBox;
import org.oslims.client.uicomponents.editbox.EditSampleBox;
import org.oslims.client.uicomponents.editbox.EnterStoragePlaceBox;
import org.oslims.client.uicomponents.editbox.SearchSamplesBox;
import org.oslims.client.view.SampleEditorView;
import org.oslims.domain.Sample;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.SimplePager;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.view.client.MultiSelectionModel;

public class SampleEditorViewImpl extends BaseViewImpl implements SampleEditorView {

	final Button addSampleButton = new Button("Add Sample");
	final Button copySamplesButton = new Button("Copy selected");
	final Button markSamplesRecievedButton = new Button("Mark as Recieved");
	final Button importSamplesButton = new Button("Import Samples");

	final EditSampleBox editSampleBox = new EditSampleBox();

	final ConfirmationBox confirmationBox = new ConfirmationBox();
	final EnterStoragePlaceBox enterStoragePlaceBox = new EnterStoragePlaceBox();
	final SearchSamplesBox searchSamplesBox = new SearchSamplesBox();
	final MultiSelectionModel<Sample> sm = new MultiSelectionModel<Sample>();

	Integer defaultPageSize = 15;
	final CellTable<Sample> sampleTable = new CellTable<Sample>(defaultPageSize);
	final SimplePager<Sample> pager = new SimplePager<Sample>(sampleTable);

	public SampleEditorViewImpl() {
		VerticalPanel vp = new VerticalPanel();

		sampleTable.setSelectionModel(sm);

		vp.add(sampleTable);
		vp.add(pager);

		HorizontalPanel hp = new HorizontalPanel();
		hp.add(addSampleButton);
		hp.add(copySamplesButton);
		hp.add(markSamplesRecievedButton);
		hp.add(importSamplesButton);

		vp.add(hp);

		vp.setStyleName("editPanel");

		initWidget(vp);
	}

	@Override
	public ConfirmationBox getConfirmationBox() {
		return confirmationBox;
	}

	@Override
	public HasClickHandlers getAddSampleButton() {
		return addSampleButton;
	}

	@Override
	public HasClickHandlers getCopySampleButton() {
		return copySamplesButton;
	}

	@Override
	public CellTable<Sample> getTable() {
		return sampleTable;
	}

	@Override
	public EditSampleBox getEditSampleBox() {
		return editSampleBox;
	}

	@Override
	public EnterStoragePlaceBox getEnterStoragePlaceBox() {
		return enterStoragePlaceBox;
	}

	@Override
	public HasClickHandlers getMarkSamplesAsRecievedButton() {
		return markSamplesRecievedButton;
	}

	@Override
	public SearchSamplesBox getSearchSamplesBox() {
		return searchSamplesBox;
	}

	@Override
	public HasClickHandlers getImportSamplesButton() {
		return importSamplesButton;
	}

	@Override
	public Integer getDefaultPageSize() {
		return defaultPageSize;
	}

	@Override
	public SimplePager<Sample> getPager() {
		return pager;
	}

	@Override
	public MultiSelectionModel<Sample> getSelectionModel() {
		return sm;
	}

}
